﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Abp.Application.Services;
using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using Abp.Domain.Repositories;
using Abp.Web.Models;
using KelonProud.Administration.Dtos;
using KelonProud.MultiTenancy;
using KelonProud.Mvc;

namespace KelonProud.Administration.Services
{
    public interface ITenantAppService : IAsyncCrudAppService<TenantOutputDto, int, PagedResultRequestDto, TenantInputDto, TenantInputDto>
    {
        Task<IEnumerable<TenantOutputDto>> GetTenants();
    }

    [WrapResult(WrapOnSuccess = false)]
    public class TenantAppService : KelonProudAsyncCrudAppService<Tenant, TenantOutputDto, int, PagedResultRequestDto, TenantInputDto, TenantInputDto>, ITenantAppService
    {
        public TenantAppService(IRepository<Tenant, int> repository) : base(repository)
        {
        }

        public override Task<TenantOutputDto> Save(TenantInputDto input)
        {
            throw new NotImplementedException();
        }

        public Task<IEnumerable<TenantOutputDto>> GetTenants()
        {
            var models = Repository.GetAllList().Select(s=>s.MapTo<TenantOutputDto>());

            return Task.FromResult(models);
        }
    }
}
